Skip to content

Feat/add gemma4 support#199

Merged
tpx818 merged 12 commits into
modelscope:mainfrom
EvineR666:feat/add-gemma4-support
Jun 2, 2026
Merged

Feat/add gemma4 support#199
tpx818 merged 12 commits into
modelscope:mainfrom
EvineR666:feat/add-gemma4-support

Conversation

@EvineR666
Copy link
Copy Markdown
Contributor

@EvineR666 EvineR666 commented May 20, 2026

PR type

  • [√] Bug Fix
  • New Feature
  • Document Updates
  • [√] More Models or Datasets Support

PR information

This PR mainly contains two changes:

  1. Add full support for Google Gemma4 series models (require transformers>=5.8.0)
  2. Fix the bug that Template and InputProcessor could not correctly process multimodal data in messages

Experiment results

The training loss curve of the Gemma4-E2B model , dataset=Self-Cognition
2ad0b9312c9833fd9bb986335e5736ba

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Gemma4 models by adding a new template and a cookbook example for multimodal FSDP2 training. It also refactors the base template's pipeline execution to use method names for better compatibility. Feedback includes fixing a copy-paste error in the evaluation dataset mapping, moving general multimodal processing logic to the base template, and improving code quality through consistent logging, removal of unused imports, and the addition of a training progress bar.

Comment thread cookbook/mm/fsdp2_gemma4_mm.py Outdated
Comment thread src/twinkle/template/gemma4.py Outdated
Comment thread cookbook/mm/fsdp2_gemma4_mm.py Outdated
Comment thread cookbook/mm/fsdp2_gemma4_mm.py Outdated
Comment thread cookbook/mm/fsdp2_gemma4_mm.py Outdated
Comment thread src/twinkle/template/base.py Outdated
Comment thread src/twinkle/template/gemma4.py Outdated
Comment thread src/twinkle/template/gemma4.py Outdated
@EvineR666 EvineR666 marked this pull request as ready for review May 20, 2026 09:06
Comment thread src/twinkle/template/gemma4.py Outdated
@tpx818
Copy link
Copy Markdown
Collaborator

tpx818 commented May 21, 2026

请在readme中补充gemma4的支持

@tpx818
Copy link
Copy Markdown
Collaborator

tpx818 commented Jun 1, 2026

附上正常训练的图

Comment thread cookbook/mm/fsdp2_gemma4_mm.py Outdated
Comment thread src/twinkle/template/__init__.py Outdated
@tpx818 tpx818 merged commit 4a4b60f into modelscope:main Jun 2, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants